<?php
/**
 * Created by PhpStorm.
 * User: alice
 * Date: 2015/12/26
 * Time: 14:14
 */

/**
 * Class Involved_UserModel
 */

class Involved_PosUserModel extends BaseModel
{

    protected $table = 'pos_user';


    /**
     * 获取用户登录信息
     * @param $mobile
     * @param $pwd
     * @return mixed
     * @author bao
     * @date 2016-01-27
     */
    public function poslogin($TerminalNo,$LoginName,$Password)
    {
        $info = DB::table($this->table)
            ->select('Posuser_id','Message', 'Name', 'DepartmentName', 'DepartmentCode')
            ->where(['TerminalNo' => $TerminalNo, 'LoginName' => $LoginName,'Password'=>$Password])
            ->first();
        if(!empty($info)){
            DB::table($this->table)->where('Posuser_id',$info->Posuser_id)->update(array('login_status' =>1 ));
        }
       return $info;
    }
   public function posloginout($TerminalNo,$LoginName)
    {
        $info = DB::table($this->table)
            ->select('Posuser_id','Message', 'Name', 'DepartmentName', 'DepartmentCode')
            ->where(['TerminalNo' => $TerminalNo, 'LoginName' => $LoginName])
            ->first();
         if(!empty($info) && $info->Posuser_id==1){
            DB::table($this->table)->where('Posuser_id',$info->Posuser_id)->update(array('login_status' =>0 ));
            return 1;
        }else{
            return 0;
        }
    }
}